<script src="./css/base/bootstrap/js/jquery-1.10.1.js"></script>
<script src="./js/index_5.js"></script>

<link href="./css/index_5.css" rel="stylesheet">


<div class="col-sm-10">
    <ol class="breadcrumb">
        <li class="active">文件管理
        </li>
        <li class="active">文件列表
        </li>
    </ol>
    <div class="panel panel-default">
        <div class="panel-heading">
            搜索
        </div>
        <div class="panel-body">



            <!--########################################-->
            <?php
            use yii\widgets\ActiveForm;

            $form=ActiveForm::begin(
                ['options'=>[
                    'enctype'=>'multipart/form-data',
                    'class' => 'form-inline line-block',

                ],
                    'method'=>'get',
                    "action"=>"/index.php?r=home/search",
                ]
            );

            ?>

            <?=$form->field($model,'key')->textInput(['maxlength' => 255,'name'=>"key",'style'=>"width:300px;float: right;margin-right:4px","value"=>isset($key)?$key:'','placeholder'=>'文件名或路径'])->label(false);?>
            <button type="submit" class="btn btn-default" style="" >开始搜索</button>
            <?=$form->field($model, 'selectproject')->radioList(['1'=>'查找项目',],['itemOptions'=>['labelOptions'=>['class'=>'radio-inline',"style"=>"padding-top:10px;padding-right:10px;font-size:14px",'name'=>"selectproject",'id'=>'selectproject']],"value"=>isset($selectproject)?$selectproject:''])->label(false) ?>

            <?php ActiveForm::end(); ?>



            <button class="btn btn-danger" onclick="batch_delete()" style="margin-left: 100px">批量删除</button>
            <button class="btn btn-danger" onclick='batch_downloada()' style="margin-left: 100px">下载全部查询结果</button>
            <!--########################################-->

        </div>
    </div>

    <!--
        列表展示
    -->
    <div class="table-responsive">
        <table class="table table-striped table-hover table-bordered"  style="table-layout:inherit">
            <thead>
            <tr>
                <!--<th><input type="checkbox" id="selectall"> 全选</th>-->
                <th><input type="checkbox" id="selectall" onchange="selectall(this)"> 全选</th>
                <th>编号</th>
<!--                <th>图标</th>-->
                <th style="word-break:break-word;width: 200px;display: none" >名称</th>
                <th  style="word-break:break-word;width: 200px">在原服务器中的相对路径</th>
                <th>所属项目</th>
                <th>文件 MD5 值</th>
                <th>文件大小</th>
                <th>有效期</th>

                <th class="text-center">操作</th>
            </tr>
            </thead>
            <tbody>
            <!--从这里开始遍历数据-->
            <?php foreach($uploads as $upload): ?>

                <tr >
                    <td style="word-break:break-word;width: 80px"><input type="checkbox" class="item"   ></td>
                    <td style="word-break:break-word;width: 50px"> <?=$upload->id?> </td> <!--id-->
                    <td style="word-break:break-word;width: 200px;display: none">
                            <?php
                                if(isset($key)){
                                    echo str_replace($key,'<span style="color:red;font-size: 17px">'.$key.'</span>',$upload->filename);
                            }else{
                                    echo $upload->filename;
                                }
                            ?>
                    </td> <!--文件名-->
                    <td style="word-break:break-word;width: 500px">
                        <?php
                        if(isset($key)){
                            echo str_replace($key,'<span style="color:red;font-size: 17px">'.$key.'</span>',$upload->sourcepath);
                        }else{
                            echo $upload->sourcepath;
                        }
                        ?>
                    </td> <!--在原服务器中的相对路径-->
                    <td style="word-break:break-word;width: 150px" ><?php
                        if(count($projects)>0){
                            foreach($projects as $project){
                                if($upload->projectid==$project->id) {
                                    if(isset($key)){
                                        echo str_replace($key,'<span style="color:red;font-size: 17px">'.$key.'</span>',$project->name);
                                    }else{
                                        echo $project->name;
                                    }
                                }
                            }
                        }else{
                            echo '';
                        }

                        ?></td>
                    <td  style="word-break:break-word;width: 270px"> <?=$upload->md5?> </td> <!--文件 MD5 值-->
                    <td  style="word-break:break-word;width: 80px">
                        <?=echoFileSize($upload->size);?>
                    </td> <!--文件大小-->
                    <td  style="word-break:break-word;width: 100px"> <?=date('Y-m-d H:i:s',$upload->deletetime)?> </td>

                    <td class="text-center " style="word-break:break-word;width: 200px">

                        <a href="/index.php?r=home/edit_one&id=<?=$upload->id?>" class="btn btn-success" >修改</a>
                        <button class="btn btn-danger" onclick="delete_one(this,<?=$upload->id?>)">删除</button>
                        <a href="/index.php?r=home/get_one&id=<?=$upload->id?>" class="btn btn-danger" >下载</a>
                    </td>
                </tr>
            <?php endforeach; ?>


            <!--到这里结束遍历数据-->
            </tbody>
        </table>

        <div class="text-center">
            <?php
            use yii\widgets\LinkPager;
            //显示分页页码
            echo LinkPager::widget(['pagination' => $pages,
                'nextPageLabel' => '下一页',
                'prevPageLabel' => '上一页',
                'hideOnSinglePage' => false,
                'maxButtonCount' => 5,
                //'options' => ['class' => 'panel-body'],//

            ]);
            ?>
        </div>
    </div>
</div>
</div>
</div>